
package shining365.programmableweb.data.history;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.jvnet.hyperjaxb3.xml.bind.annotation.adapters.XMLGregorianCalendarAsDate;
import org.jvnet.hyperjaxb3.xml.bind.annotation.adapters.XmlAdapterUtils;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.HashCode;
import org.jvnet.jaxb2_commons.lang.ToString;
import org.jvnet.jaxb2_commons.lang.builder.JAXBEqualsBuilder;
import org.jvnet.jaxb2_commons.lang.builder.JAXBHashCodeBuilder;
import org.jvnet.jaxb2_commons.lang.builder.JAXBToStringBuilder;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="timePoint" maxOccurs="unbounded" minOccurs="0">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element ref="{http://shining365.cn/programmableweb/data/history}api" maxOccurs="unbounded" minOccurs="0"/>
 *                 &lt;/sequence>
 *                 &lt;attribute name="date" use="required" type="{http://www.w3.org/2001/XMLSchema}date" />
 *                 &lt;attribute name="averageCentrality" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "timePoint"
})
@XmlRootElement(name = "history")
@Entity(name = "shining365.programmableweb.data.history.History")
@Table(name = "HISTORY")
@Inheritance(strategy = InheritanceType.JOINED)
public class History
    implements Equals, HashCode, ToString
{

    protected List<History.TimePoint> timePoint;
    @XmlAttribute(name = "Hjid")
    protected Long hjid;

    /**
     * Gets the value of the timePoint property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the timePoint property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getTimePoint().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link History.TimePoint }
     * 
     * 
     */
    @OneToMany(targetEntity = shining365.programmableweb.data.history.History.TimePoint.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "TIMEPOINT_HISTORY_ID")
    public List<History.TimePoint> getTimePoint() {
        if (timePoint == null) {
            timePoint = new ArrayList<History.TimePoint>();
        }
        return this.timePoint;
    }

    /**
     * 
     * 
     */
    public void setTimePoint(List<History.TimePoint> timePoint) {
        this.timePoint = timePoint;
    }

    @Transient
    public boolean isSetTimePoint() {
        return ((this.timePoint!= null)&&(!this.timePoint.isEmpty()));
    }

    public void unsetTimePoint() {
        this.timePoint = null;
    }

    public void equals(Object object, EqualsBuilder equalsBuilder) {
        if (!(object instanceof History)) {
            equalsBuilder.appendSuper(false);
            return ;
        }
        if (this == object) {
            return ;
        }
        final History that = ((History) object);
        equalsBuilder.append(this.getTimePoint(), that.getTimePoint());
    }

    public boolean equals(Object object) {
        if (!(object instanceof History)) {
            return false;
        }
        if (this == object) {
            return true;
        }
        final EqualsBuilder equalsBuilder = new JAXBEqualsBuilder();
        equals(object, equalsBuilder);
        return equalsBuilder.isEquals();
    }

    public void hashCode(HashCodeBuilder hashCodeBuilder) {
        hashCodeBuilder.append(this.getTimePoint());
    }

    public int hashCode() {
        final HashCodeBuilder hashCodeBuilder = new JAXBHashCodeBuilder();
        hashCode(hashCodeBuilder);
        return hashCodeBuilder.toHashCode();
    }

    public void toString(ToStringBuilder toStringBuilder) {
        {
            List<History.TimePoint> theTimePoint;
            theTimePoint = this.getTimePoint();
            toStringBuilder.append("timePoint", theTimePoint);
        }
    }

    public String toString() {
        final ToStringBuilder toStringBuilder = new JAXBToStringBuilder(this);
        toString(toStringBuilder);
        return toStringBuilder.toString();
    }

    /**
     * Gets the value of the hjid property.
     * 
     * @return
     *     possible object is
     *     {@link Long }
     *     
     */
    @Id
    @Column(name = "HJID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getHjid() {
        return hjid;
    }

    /**
     * Sets the value of the hjid property.
     * 
     * @param value
     *     allowed object is
     *     {@link Long }
     *     
     */
    public void setHjid(Long value) {
        this.hjid = value;
    }


    /**
     * <p>Java class for anonymous complex type.
     * 
     * <p>The following schema fragment specifies the expected content contained within this class.
     * 
     * <pre>
     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element ref="{http://shining365.cn/programmableweb/data/history}api" maxOccurs="unbounded" minOccurs="0"/>
     *       &lt;/sequence>
     *       &lt;attribute name="date" use="required" type="{http://www.w3.org/2001/XMLSchema}date" />
     *       &lt;attribute name="averageCentrality" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "api"
    })
    @Entity(name = "shining365.programmableweb.data.history.History$TimePoint")
    @Table(name = "TIMEPOINT")
    @Inheritance(strategy = InheritanceType.JOINED)
    public static class TimePoint
        implements Equals, HashCode, ToString
    {

        protected List<shining365.programmableweb.data.history.Api> api;
        @XmlAttribute(required = true)
        @XmlSchemaType(name = "date")
        protected XMLGregorianCalendar date;
        @XmlAttribute(required = true)
        protected double averageCentrality;

        /**
         * Gets the value of the api property.
         * 
         * <p>
         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a <CODE>set</CODE> method for the api property.
         * 
         * <p>
         * For example, to add a new item, do as follows:
         * <pre>
         *    getApi().add(newItem);
         * </pre>
         * 
         * 
         * <p>
         * Objects of the following type(s) are allowed in the list
         * {@link shining365.programmableweb.data.history.Api }
         * 
         * 
         */
        @OneToMany(targetEntity = shining365.programmableweb.data.history.Api.class, cascade = {
            CascadeType.ALL
        })
        @JoinColumn(name = "API_TIMEPOINT_ID")
        public List<shining365.programmableweb.data.history.Api> getApi() {
            if (api == null) {
                api = new ArrayList<shining365.programmableweb.data.history.Api>();
            }
            return this.api;
        }

        /**
         * 
         * 
         */
        public void setApi(List<shining365.programmableweb.data.history.Api> api) {
            this.api = api;
        }

        @Transient
        public boolean isSetApi() {
            return ((this.api!= null)&&(!this.api.isEmpty()));
        }

        public void unsetApi() {
            this.api = null;
        }

        /**
         * Gets the value of the date property.
         * 
         * @return
         *     possible object is
         *     {@link XMLGregorianCalendar }
         *     
         */
        @Transient
        public XMLGregorianCalendar getDate() {
            return date;
        }

        /**
         * Sets the value of the date property.
         * 
         * @param value
         *     allowed object is
         *     {@link XMLGregorianCalendar }
         *     
         */
        public void setDate(XMLGregorianCalendar value) {
            this.date = value;
        }

        @Transient
        public boolean isSetDate() {
            return (this.date!= null);
        }

        /**
         * Gets the value of the averageCentrality property.
         * 
         */
        @Basic
        @Column(name = "AVERAGECENTRALITY")
        public double getAverageCentrality() {
            return averageCentrality;
        }

        /**
         * Sets the value of the averageCentrality property.
         * 
         */
        public void setAverageCentrality(double value) {
            this.averageCentrality = value;
        }

        @Transient
        public boolean isSetAverageCentrality() {
            return true;
        }

        public void equals(Object object, EqualsBuilder equalsBuilder) {
            if (!(object instanceof History.TimePoint)) {
                equalsBuilder.appendSuper(false);
                return ;
            }
            if (this == object) {
                return ;
            }
            final History.TimePoint that = ((History.TimePoint) object);
            equalsBuilder.append(this.getApi(), that.getApi());
            equalsBuilder.append(this.getDate(), that.getDate());
            equalsBuilder.append(this.getAverageCentrality(), that.getAverageCentrality());
        }

        public boolean equals(Object object) {
            if (!(object instanceof History.TimePoint)) {
                return false;
            }
            if (this == object) {
                return true;
            }
            final EqualsBuilder equalsBuilder = new JAXBEqualsBuilder();
            equals(object, equalsBuilder);
            return equalsBuilder.isEquals();
        }

        public void hashCode(HashCodeBuilder hashCodeBuilder) {
            hashCodeBuilder.append(this.getApi());
            hashCodeBuilder.append(this.getDate());
            hashCodeBuilder.append(this.getAverageCentrality());
        }

        public int hashCode() {
            final HashCodeBuilder hashCodeBuilder = new JAXBHashCodeBuilder();
            hashCode(hashCodeBuilder);
            return hashCodeBuilder.toHashCode();
        }

        public void toString(ToStringBuilder toStringBuilder) {
            {
                List<shining365.programmableweb.data.history.Api> theApi;
                theApi = this.getApi();
                toStringBuilder.append("api", theApi);
            }
            {
                XMLGregorianCalendar theDate;
                theDate = this.getDate();
                toStringBuilder.append("date", theDate);
            }
            {
                double theAverageCentrality;
                theAverageCentrality = this.getAverageCentrality();
                toStringBuilder.append("averageCentrality", theAverageCentrality);
            }
        }

        public String toString() {
            final ToStringBuilder toStringBuilder = new JAXBToStringBuilder(this);
            toString(toStringBuilder);
            return toStringBuilder.toString();
        }

        @Id
        @Column(name = "DATEITEM")
        @Temporal(TemporalType.DATE)
        public Date getDateItem() {
            return XmlAdapterUtils.unmarshall(XMLGregorianCalendarAsDate.class, this.getDate());
        }

        public void setDateItem(Date target) {
            setDate(XmlAdapterUtils.marshall(XMLGregorianCalendarAsDate.class, target));
        }

    }

}
